package com.example.demo1.common;

import lombok.Data;

@Data
public class Result {
    private static final int SUCCESS_CODE = 200;
    private static final int FAIL_CODE = 400;

    private int code;
    private String msg;
    private Object data;

    private Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result success(Object data) {
        return new Result(SUCCESS_CODE, "success", data);
    }

    public static Result success(String msg) {
        return new Result(SUCCESS_CODE, msg, null);
    }

    public static Result fail(String msg) {
        return new Result(FAIL_CODE, msg,null);
    }

}
